package cn.wolfcode.custom.service.impl;

import java.util.List;

import cn.wolfcode.common.utils.DateUtils;
import cn.wolfcode.common.utils.SecurityUtils;
import cn.wolfcode.custom.dto.CustomerVisitDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.wolfcode.custom.mapper.CustomerVisitMapper;
import cn.wolfcode.custom.domain.CustomerVisit;
import cn.wolfcode.custom.service.ICustomerVisitService;

/**
 * 拜访信息Service业务层处理
 * 
 * @author zhangyf
 * @date 2023-05-02
 */
@Service
public class CustomerVisitServiceImpl implements ICustomerVisitService 
{
    @Autowired
    private CustomerVisitMapper customerVisitMapper;

    /**
     * 查询拜访信息
     * 
     * @param id 拜访信息主键
     * @return 拜访信息
     */
    @Override
    public CustomerVisit selectCustomerVisitById(Long id)
    {
        return customerVisitMapper.selectCustomerVisitById(id);
    }

    /**
     * 查询拜访信息列表
     * 
     * @param customerVisit 拜访信息
     * @return 拜访信息
     */
    @Override
    public List<CustomerVisit> selectCustomerVisitList(CustomerVisit customerVisit)
    {
        return customerVisitMapper.selectCustomerVisitList(customerVisit);
    }

    /**
     * 新增拜访信息
     * 
     * @param customerVisit 拜访信息
     * @return 结果
     */
    @Override
    public int insertCustomerVisit(CustomerVisit customerVisit)
    {
        // 设置当前录入人
        customerVisit.setInputUser(SecurityUtils.getUserId());
        // 设置当前时间
        customerVisit.setInputTime(DateUtils.getNowDate());
        return customerVisitMapper.insertCustomerVisit(customerVisit);
    }

    /**
     * 修改拜访信息
     * 
     * @param customerVisit 拜访信息
     * @return 结果
     */
    @Override
    public int updateCustomerVisit(CustomerVisit customerVisit)
    {
        return customerVisitMapper.updateCustomerVisit(customerVisit);
    }

    /**
     * 批量删除拜访信息
     * 
     * @param ids 需要删除的拜访信息主键
     * @return 结果
     */
    @Override
    public int deleteCustomerVisitByIds(Long[] ids)
    {
        return customerVisitMapper.deleteCustomerVisitByIds(ids);
    }

    /**
     * 删除拜访信息信息
     * 
     * @param id 拜访信息主键
     * @return 结果
     */
    @Override
    public int deleteCustomerVisitById(Long id)
    {
        return customerVisitMapper.deleteCustomerVisitById(id);
    }

    @Override
    public List<CustomerVisit> selectCustomerVisitDTOList(CustomerVisitDTO customerVisitDTO) {
        return customerVisitMapper.selectCustomerVisitDTOList(customerVisitDTO);
    }
}
